﻿param 
(
    [string]$ConfigFile = $(throw '- Need parameter ConfigFile (e.g. "configurationitems.xml")'),
	[string]$SiteUrl = $(throw '- Need parameter SiteUrl (e.g. "http://sp")')
)

## check to ensure Microsoft.SharePoint.PowerShell is loaded if not using the SharePoint Management Shell 
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} 
if ($snapin -eq $null) 
{    
	Write-Host "Loading SharePoint Powershell Snapin"    
	Add-PSSnapin "Microsoft.SharePoint.Powershell" 
}

$configFilePath = Join-Path $PWD $ConfigFile
Write-Host $configFilePath
[System.Reflection.Assembly]::LoadWithPartialName("Precio.SharePoint.Core")
[Precio.SharePoint.Core.ExecutingEnvironment]::Current.SetCurrentUrl($SiteUrl)
[Precio.SharePoint.Core.Configuration.ConfigManager]::EnsureConfiguration($configFilePath)

Write-Host "All good!"